package com.yidi.system.repository;

import com.yidi.common.core.Repository.BaseRepository;
import com.yidi.system.domain.SysPost;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author ：Xn
 * @ClassName: SysPostRepository
 * @date ：2021-10-19 14:05
 * @describe ：岗位
 */
@Repository
public interface SysPostRepository extends BaseRepository<SysPost,Long> {

    SysPost findByPostName(String postName);

    SysPost findByPostCode(String postCode);

    @Query(nativeQuery = true, value = "select p.id from sys_post p left join sys_user_post up on up.post_id = p.id" +
            " left join sys_user u on u.id = up.user_id where u.id = ?1")
    List<Long> selectPostListByUserId(Long userId);
}
